package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F60.2.7   Chip Card Authentication Reliability Indicator：芯片卡授权可靠性指示
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F60_2_7_AuthenticationReliabilityEnum {
    _0("0", "第8位或后继位存在时的填充值"),
    _1("1", "受理方表示卡的授权可能不可靠"),
    _2("2", "CUPS指示受理方未参与卡片的验证"),
    _3("3", "CUPS指示发卡方未参与卡片的验证"),
    _4("4", "用于银联CUPS系统向发卡方指示该交易使用银联提供的Token服务。在受理方上送该域时，取值填写原有取值（0~3）不变"),
    ;

    private String code;
    private String desc;

    F60_2_7_AuthenticationReliabilityEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F60_2_7_AuthenticationReliabilityEnum find(String code) {
        F60_2_7_AuthenticationReliabilityEnum result = Arrays.stream(F60_2_7_AuthenticationReliabilityEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
